var cubeBox = document.getElementsByClassName('cube-box')[0];
var cube = document.getElementsByClassName('cube')[0];
var xDeg = 30;
var yDeg = 30;
var startRotate = false;


cubeBox.onmousedown = function(e) {
	if (this != e.target) {
		return
	};
	startRotate = true;
	console.log('开始旋转！')
};

cubeBox.onmouseup = function(e) {
	if (this != e.target) {
		return
	};
	startRotate = false;
	console.log('结束旋转！')
};
var currentTime = 0;
function slowDown(){};
function foo(){
	
};

document.body.onmousemove = function(e) {
	if (startRotate) {
		xDeg -= e.movementY;
		yDeg += e.movementX;
		cube.style.transform = `rotateX(${xDeg}deg) rotateY(${yDeg}deg)`;
	}
};

var faceNodes = document.getElementsByClassName('face');
var classArray = ['bottom', 'top', 'left', 'right', 'front', 'back'];

// ----------生成立方体-----------
document.getElementById('start-cube').onclick = function(e) {
	for (var i = 0; i < faceNodes.length; i++) {
		faceNodes[i].className += (' ' + classArray[i]);
	};
};
// ----------打回原形-----------
document.getElementById('back-flat').onclick = function(e) {
	for (var i = 0; i < faceNodes.length; i++) {
		faceNodes[i].className = 'face';
	};
};
